export default {
  data() {
    return {
      sortable: false,
      sortArr: [],
    }
  },
  mounted() {
    this.$bus.$on('changeSortArr', (v) => {
      this.sortArr = v
    })
  },
  beforeDestroy() {
    this.$bus.$off('changeSortArr')
  },
  methods: {
    //排序
    handleSort() {
      this.sortable = true
      this.$bus.$emit('changeSortFlag', this.sortable)
    },
    //取消排序
    handleCancelSort() {
      this.sortable = false
      this.$bus.$emit('changeSortFlag', this.sortable)
      this.$bus.$emit('refreshNewsContentsList')
    },
    //保存排序
    async handleSaveSort() {
      this.sortable = false
      await this.$store.dispatch('dragSortNewsContents', this.sortArr)
      this.$bus.$emit('changeSortFlag', this.sortable)
      this.refreshList()
    },
  },
}
